package com.shelpe.services.sinbad.dto;

import java.util.Date;
import org.apache.commons.lang.time.DateUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.shelpe.services.sinbad.entity.jpa.MobileAdgroupDetail;
import lombok.Data;

/**
 * @description 我的养分 前端数据模型
 * 
 * @author letian@shelpe.com
 * @date 2017年8月28日 下午7:01:34
 */
@Data
public class MobileAdgroupDto {

	@JsonProperty("mobile_adgroup_id")
	private long mobileAdgroupID;

	@JsonProperty("adgroup_id")
	private long adgroupID;

	@JsonProperty("campaign_id")
	private long campaignID;

	@JsonProperty("product_title")
	private String productTitle;

	@JsonProperty("product_img")
	private String productImg;

	@JsonProperty("campaign_name")
	private String campaignName;

	@JsonProperty("keywords_num")
	private int keywordsNum;

	@JsonProperty("rema_days")
	private int remaDays;

	@JsonProperty("status")
	private Integer status;// starting(1), finish(2), exception(3);

	public void from(MobileAdgroupDetail mobileAdgroup) {
		Date now = new Date();
		Date expireDate = DateUtils.addDays(mobileAdgroup.getCreatedTime(), 7);
		this.mobileAdgroupID = mobileAdgroup.getAutoID();
		this.adgroupID = mobileAdgroup.getAdgroupID();
		this.campaignID = mobileAdgroup.getCampaignID();
		this.status = mobileAdgroup.getStatus().getValue();
		this.remaDays = (int) ((expireDate.getTime() - now.getTime()) / (1000 * 60 * 60 * 24));
	}

}
